home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / programm.ing / ams__l~1.zoo / src / cookie.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1993-09-13  |  806 b   |  53 lines

  1. #include <stdio.h>
  2. #include <osbind.h>
  3. #include <sysvars.h>
  4.  
  5. static int cookie;
  6. static int cookieval;
  7. static int getcookie()
  8. {
  9.     if (*_p_cookies) {
  10.         cookieval=(*_p_cookies)[cookie*2+1];
  11.         cookie=(*_p_cookies)[cookie*2];
  12.     } else {
  13.         cookie=0;
  14.         cookieval=0;
  15.     }
  16. }
  17. static int findcookie()
  18. {
  19.     if (*_p_cookies) {
  20.         int i;
  21.         for (i=0; (*_p_cookies)[i] && (*_p_cookies)[i]!=cookie; i+=2)
  22.             ;
  23.         if ((*_p_cookies)[i]==cookie) {
  24.             cookieval=(*_p_cookies)[i+1];
  25.         } else {
  26.             cookie=0;
  27.             cookieval=0;
  28.         }
  29.     } else {
  30.         cookie=0;
  31.         cookieval=0;
  32.     }
  33. }
  34.  
  35. int GetCookieByNumber(int i)
  36. {
  37.     cookie=i;
  38.     Supexec(getcookie);
  39.     return cookie;
  40. }
  41.  
  42. int GetCookie(int i)
  43. {
  44.     cookie=i;
  45.     Supexec(findcookie);
  46.     return cookieval;
  47. }
  48.  
  49. int GetCookieNamed(char name[4])
  50. {
  51.     return GetCookie((name[0]<<24)|(name[1]<<16)|(name[2]<<8)|name[3]);
  52. }
  53.